<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="./plugins/element-ui/index.css"/>
    <link rel="stylesheet" href="./styles/common.css"/>
    <link rel="stylesheet" href="./styles/page.css"/>
</head>
<body>
<div class="addBrand-container" id="member-add-app">
    <div class="container">
        <el-form
                ref="ruleForm"
                :model="ruleForm"
                :inline="false"
                label-width="180px"
                class="demo-ruleForm"
        >
            <el-form-item
                    label="用户:"
                    prop="uName"
            >
                <el-input
                        v-model="ruleForm.uName"
                        placeholder="请输入用户名"
                        maxlength="20"
                        :disabled="true"
                />
            </el-form-item>

            <el-form-item
                    label="类型:"
                    prop="uType"
            >
                <el-radio-group v-model="ruleForm.uType">
                    <el-radio label="1" :disabled="true">管理员</el-radio>
                    <el-radio label="0" :disabled="true">普通用户</el-radio>
                </el-radio-group>
            </el-form-item>

            <el-form-item
                    label="备注:"
                    prop="uMemo"
            >
                <el-input
                        v-model="ruleForm.uMemo"
                        placeholder="请输入备注"
                        type="textarea"
                        style="width: 300px"
                        :rows="5"
                        maxlength="200"
                        :disabled="true"
                />
            </el-form-item>

            <div class="subBox address">
                <el-form-item>
                    <el-button @click="goBack()">
                        取消
                    </el-button>
                </el-form-item>
            </div>
        </el-form>
    </div>
</div>
<!-- 开发环境版本，包含了有帮助的命令行警告 -->
<script src="./plugins/vue/vue.js"></script>
<!-- 引入组件库 -->
<script src="./plugins/element-ui/index.js"></script>
<!-- 引入axios -->
<script src="./plugins/axios/axios.min.js"></script>
<script src="./js/request.js"></script>
<script src="./api/member.js"></script>
<script src="./js/validate.js"></script>
<script src="./js/index.js"></script>
<script>
    new Vue({
        el: '#member-add-app',
        data() {
            return {
                id: '',
                ruleForm: {
                    'uName': '',
                    'uPwd' : '',
                    'uPwd2' : '',
                    'uType': '',
                    'uMemo': ''
                }
            }
        },
        computed: {
        },
        created() {
            this.id = requestUrlParam('id')
            if (this.id) {
                this.init()
            }
        },
        mounted() {
        },
        methods: {
            async init() {
                queryEmployeeById(this.id).then(res => {
                    console.log(res)
                    if (String(res.code) === '1') {
                        console.log(res.data)
                        this.ruleForm = res.data
                        this.ruleForm.uType = res.data.uType === 0 ? '0' : '1'
                        this.ruleForm.uPwd2 = res.data.uPwd
                    } else {
                        this.$message.error(res.msg || '操作失败')
                    }
                })
            },
            goBack() {
                window.location.href= '/backend/list.html'
            }
        }
    })
</script>
</body>
</html>
